﻿using System.Windows;
using System.Windows.Controls;
using DevExpress.AgDataGrid;
using DevExpress.AgDataGrid.Data;
using DevExpress.AgDataGrid.Data.Helpers;

namespace Test.Silverlight.DataGrid {
    public partial class ColumnTypes : UserControl {
        public ColumnTypes() {
            InitializeComponent();
            grid.DataSource = EmployeesData.DataSource;
        }
        void AgDataGridColumn_PrepareCellDisplayElement_1(object sender, PrepareCellDisplayElementEventArgs e) {
            double val = (double)(e.CellData.CellValue ?? 0.0);
            StackPanel moneyPanel = (StackPanel)e.DisplayElement;
            ((FrameworkElement)moneyPanel.FindName("Child20")).Opacity = val > 0 ? 1 : 0;
            ((FrameworkElement)moneyPanel.FindName("Child40")).Opacity = val > 20 ? 1 : 0;
            ((FrameworkElement)moneyPanel.FindName("Child60")).Opacity = val > 40 ? 1 : 0;
            ((FrameworkElement)moneyPanel.FindName("Child80")).Opacity = val > 60 ? 1 : 0;
            ((FrameworkElement)moneyPanel.FindName("Child100")).Opacity = val > 80 ? 1 : 0;
        }
    }
}
